package com.xiaohai.big_event_system.common;

import lombok.Data;

@Data
public class R<T> {
    private int code;
    private String message;
    private T data;

    // 构造函数
    public R(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    // 成功的静态方法
    public static <T> R<T> success(T data, String message) {
        return new R<>(200, message, data);
    }

    // 错误的静态方法
    public static <T> R<T> error(int code, String message) {
        return new R<>(code, message, null);
    }
}
